import Vue from 'vue'
import Router from 'vue-router'

const router = [
  {
    path: '/',
    name: 'buildForm',
    // webpackChunkName => 定义 按需加载组件的 webpackChunkName 名称
    component: () => import( /* webpackChunkName: "BuildForm" */ '@/components/buildForm'),
  },
  {
    path: '/preview',
    name: 'preview',
    component: () => import(/* webpackChunkName: "preview" */'@/components/preview/index')
  },
  {
    path: '/posts',
    name: 'posts',
    component: () => import(/* webpackChunkName: "posts" */'@/components/posts/index'),
    // redirect: '/posts',
    children: [
      {
        path: '/posts/list',
        name: 'list',
        component: () => import(/* webpackChunkName: "list"  */ '@/components/posts/list')
      },
      {
        path: '/detail/:id',
        name: 'detail',
        component: () => import(/* webpackChunkName: "detail"  */ '@/components/posts/detail')
      }
    ]
  },
]


Vue.use(Router)

export default new  Router({
  routes:router
})